/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-13 07:01:24
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-16 06:59:19
 */
import 'package:flutter/material.dart';
import 'package:flutter_data_center/controller/home_controller.dart';
import 'package:get/get.dart';
import 'components/app_list.dart';
import 'components/device_list.dart';
import 'components/module_statistic.dart';

class ModuleScreen extends StatefulWidget {
  const ModuleScreen({Key key}) : super(key: key);
  static String routeName = "/module";

  @override
  _ModuleScreenState createState() => _ModuleScreenState();
}

class _ModuleScreenState extends State<ModuleScreen> {
  HomeController _homeController = Get.put(HomeController());

  @override
  void initState() {
    super.initState();
    // if (_homeController.moduleStatisticsList.length == 0) {

    // }
    _homeController.getModuleStatistics();
    if (_homeController.appList.length == 0) {
      _homeController.getApp();
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        title: Text("智慧应用"),
        backgroundColor: Colors.white,
        elevation: 0,
        centerTitle: true,
        leading: BackButton(
          onPressed: () {
            Navigator.of(context).pop();
          },
        ),
      ),
      body: SafeArea(
        child: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 27, vertical: 18),
          child: SingleChildScrollView(
            physics: BouncingScrollPhysics(),
            child: Column(
              children: [
                ModuleStatistic(),
                SizedBox(height: 20),
                DeviceList(),
                SizedBox(height: 20),
                AppList(),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
